/**
* +--------------------------------------------------------+
* @Created by Goland.
* @Category user.go
* @Depiction
* @Author hwy <429208948@qq.com>
* @Date 2021/9/24  11:37
* +--------------------------------------------------------+
 */
package api

import (
	"github.com/gogf/gf/net/ghttp"
	"go_frames/app/model"
	"go_frames/app/service"
	"go_frames/app/utils/response"
)

// 用户api管理对象
var User = new(userApi)

type userApi struct{}

func (a *userApi) List(r *ghttp.Request) {
	// 参数验证
	var apiReq *model.UserPageReq
	if err := r.Parse(&apiReq); err != nil {
		response.ErrorResp(r, -1, err.Error())
	}

	// 调用查询列表方法
	list, count, err := service.User.GetList(apiReq)
	if err != nil {
		response.ErrorResp(r, -1, err.Error())
	}

	response.ListResp(r, 0, "ok", count, list)

	// 返回结果
}
